package edu.ustb.Controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.ustb.service.GoodsService;
import edu.ustb.service.GoodsServiceImpl;

@WebServlet("/admin/goods/delete.do")
public class GoodsDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public GoodsDeleteServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String goodsId = request.getParameter("goodsId");
		GoodsService goodsService=new GoodsServiceImpl();
		int state = goodsService.delete(goodsId);
		System.out.println("delete state is:"+state);
		response.sendRedirect(request.getContextPath()+"/admin/goods/search.action");
	}

}
